package com.zzz.tesr.test1;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class SampleJob {

    @XxlJob("sampleJobHandler")
    public void sampleJobHandler() throws Exception {
        System.out.println("Xxl-Job 定时任务执行中...");
    }
    @XxlJob("sendMsgShardingHandler")
    public void sendMsgShardingHandler() {
        System.out.println("任务开始时间:" + new Date());
        int shardTotal = XxlJobHelper.getShardTotal();
        int shardIndex = XxlJobHelper.getShardIndex();
        System.out.println("分片:shardTotal" + shardTotal + "shardIndex" + shardIndex);
    }
}
